package com.jinmdz.fmis.dao.dao.provider;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

/**
 * 火化炉Provider
 *
 * @author LiCongLu
 * @date 2020-02-15 17:54
 */
public class CremationFurnaceProvider {

    /**
     * 按照类型字典编码值查询火化炉
     *
     * @param dictCode 类型字典编码
     * @param dataCode 类型编码
     * @return
     * @author LiCongLu
     * @date 2020-02-15 19:39
     */
    public String listCremationFurnaceByDictCode(@Param("dictCode") String dictCode, @Param("dataCode") Integer dataCode) {
        return new SQL() {
            {
                StringBuilder builder = new StringBuilder();
                builder.append(" cremation_furnace.id,furnace_type_code,furnace_code,furnace_describe,furnace_state,disable_state");
                builder.append(" ,cremation_furnace.sort,cremation_furnace.remark,cremation_furnace.version ");
                SELECT(builder.toString());
                FROM(" cremation_furnace ");
                LEFT_OUTER_JOIN(" data_dictionary on data_dictionary.data_code = cremation_furnace.furnace_type_code  ");
                WHERE(" cremation_furnace.deleted = 0 and data_dictionary.deleted = 0 ");
                WHERE(" data_dictionary.dict_code = #{dictCode}");
                WHERE(" data_dictionary.data_code = #{dataCode} ");
                ORDER_BY(" cremation_furnace.sort ");
            }
        }.toString();
    }


    /**
     * 按照主键获取火化炉信息
     *
     * @param id 主键
     * @return
     * @author LiCongLu
     * @date 2020-02-17 19:39
     */
    public String getCremationFurnaceViewById(@Param("id") Integer id) {
        return new SQL() {
            {
                StringBuilder builder = new StringBuilder();
                builder.append(" cremation_furnace.id,furnace_type_code,furnace_code,furnace_describe,furnace_state,disable_state");
                builder.append(" ,cremation_furnace.sort,cremation_furnace.remark,cremation_furnace.version ");
                SELECT(builder.toString());
                FROM(" cremation_furnace ");
                WHERE(" cremation_furnace.deleted = 0");
                WHERE(" cremation_furnace.id = #{id}");
            }
        }.toString();
    }

    /**
     * 按照类型字典编码值查询火化炉
     *
     * @param dictCode 类型字典编码
     * @param dataCode 类型编码
     * @return
     * @author LiCongLu
     * @date 2020-02-17 19:37
     */
    public String listCremationFurnaceViewByDictCode(@Param("dictCode") String dictCode, @Param("dataCode") Integer dataCode) {
        return new SQL() {
            {
                StringBuilder builder = new StringBuilder();
                builder.append(" cremation_furnace.id,furnace_type_code,furnace_code,furnace_describe,furnace_state,disable_state");
                builder.append(" ,cremation_furnace.sort,cremation_furnace.remark,cremation_furnace.version");
                SELECT(builder.toString());
                FROM(" cremation_furnace ");
                LEFT_OUTER_JOIN(" data_dictionary on data_dictionary.data_code = cremation_furnace.furnace_type_code  ");
                WHERE(" cremation_furnace.deleted = 0 and data_dictionary.deleted = 0 ");
                WHERE(" data_dictionary.dict_code = #{dictCode}");
                WHERE(" data_dictionary.data_code = #{dataCode} ");
                ORDER_BY(" cremation_furnace.sort ");
            }
        }.toString();
    }
}
